package Redis.sds;

import java.util.HashMap;

/**
 * @author welsir
 * @version 1.0
 * @description: TODO
 * @date 2022/10/2 14:57
 */
public class RedisUitl {
    private static HashMap<String, String> hashMap = new HashMap<>();

    public static int append(String key, String appendText) {
        String value = null;
        String newValue = null;
        if (!hashMap.containsKey(key)) {
            hashMap.put(key, appendText);
            SDS sds = new SDS(appendText);
            return sds.len;
        }
        value = hashMap.get(key);
        SDS sds = new SDS(value);
        sds.append(sds,appendText);
        newValue = value + appendText;
        hashMap.put(key, newValue);
        return new SDS(newValue).len;
    }

    public static void show(SDS sds){
        SDS.printBuf(sds);
    }
}
